<template>
  <div>
    <van-nav-bar title="购物车" left-text="返回" left-arrow @click-left="fan" />
    <div class="goods">
      <my-goods v-for="obj in list" :key="obj.id" :gobj="obj"></my-goods>
      <my-footer @changeAll="allFn" :arr="list"></my-footer>
    </div>
  </div>
</template>

<script>
import MyFooter from "./MyFooter.vue";
import MyGoods from "./MyGoods.vue";
import axios from "axios";
export default {
  components: {
    MyGoods,
    MyFooter,
  },
  data() {
    return {
      list: [{}], //空的商品数据
    };
  },
  created() {
    this.getquredis();
  },
  methods: {
    getquredis() {
      axios({
          //直接取值
               
        url: "/api/product/getquredis",
        // params:{userId:this.$route.query.userId}
        params:{userId:JSON.parse(localStorage.getItem('user')).userId},
      }).then((res) => {
        console.log(res);
        this.list = res.data;
      });
    },
    fan(){
this.$router.go(-1)
    },

    allFn(bool) {
      this.list.forEach((obj) => (obj.goods_state = bool));
    },
  },
};
</script>

<style>
.shop-top {
  float: left;
  text-align: center;
  width: 100%;
  height: 40px;
}

.goods {
 width: 100%;
  margin-bottom: 15px;
  float: left;
}
</style>